var rows1=10;


var myselfPage1;
var myselfPath1;
var myselfSucc1;

var pageEnd1;
var pageIndex1;

/***给页面分页赋值****/
function showpage_1(total,pages){
	var nowpage=Number(pages)/rows1;
	var allpage=Math.ceil(Number(total)/rows1);
	pageEnd1=allpage-1;
	pageIndex1=nowpage;
	$("#allcount_1").html(total);
	$("#rowscount_1").html(rows1);
	$("#allpage_1").html(allpage);
	$("#nowpage_1").html(nowpage+1);
	var option="";
	for(var i=0;i<allpage;i++){
		var val=i+1;
		option+="<option value='"+i+"'>"+val+"</option>"
	}
	$("#pagination_others select").html(option);
	$("#pagination_others select").val(nowpage);
}

	/**
 * 获取数据
 */
function getPageData_1(param,path,succ){
	myselfPath1=path;
	myselfPage1=param;
	myselfSucc1=succ;
   	param.ajax(path,function(data){
		showpage_1(data.total,data.page);
		succ(data);
		
		//记住当前所选的页面，目的是从其他页面再返回清单页时，保持之前所选的页面
		// window.localStorage.setItem("page",data.page);
	});
}

/**
 * 首页
 * 
 */
function firstPage_1(){
	turnPage_1("0");
}

/**
 * 最后一页
 */
function lastPage_1(){
	turnPage_1(getpageEnd_1());
}

/**
 * 上一页
 */
function prePage_1(){
	var index=getPathIndex_1()-1;
	if(index<0){
		alert("已经是首页了");
	}else{
		turnPage_1(index);
	}
}

/**
 * 下一页
 */
function nextPage_1(){
	var index=getPathIndex_1()+1;
	if(index>getpageEnd_1()){
		alert("已经是最后一页了");
	}else{
		turnPage_1(index);
	}
}

/**
 * 跳转
 */
function jumpPage_1(obj){
	var val=$(obj).val();
	turnPage_1(val);
}


/**
 * 修改page值，显示当前页数据
 * @param index
 * @return
 */
function turnPage_1(index){
	myselfPage1.json["page"]=index*rows1;
	getPageData_1(myselfPage1,myselfPath1,myselfSucc1);
}




function getPathIndex_1(){
	return pageIndex1;
}

/**
 * 最后一页
 * @return
 */
function getpageEnd_1(){
	return pageEnd1;
}
